<?php
	class selectFunction extends baseFunction{
			public $functionConent;
			function getFunctionName(){
				//$table = $this->getTableStruct()->getTable();
				return 'select';
			}
			function getFunctionArg(){
				return '$arg=array()';	
			}
			function getFunctionConent(){				
				$this->replaceFunContent('[contentGlobal]','global $db;');	
				$this->replaceFunContent("[contentDefultsArray]",$this->getContentDefultsArray());
				//$this->replaceFunContent("[contentMergeArray]");
				return $this->functionConent;
			}
			function getContentDefultsArray(){				
				$table = $this->getTableFiled();
				$defultsContent = false;
				$arrayString    = false;
				
				$defults = array("desc"=>false,'order'=>false,"offset"=>false,'limit'=>false);

				foreach($table as $key=>$val){
					if($val->primary_key == 1){
						continue;	
					}
					//如果当前字段是主键					
					$array[$key] = false;					
				}
				$args = array_merge($array,$defults);
				//开始生成数据
				$defultsContent = '$defults = array(\n[content]);';
				//
				foreach($args as $key=>$val){
					$arrayString .= "\t{$key}  => false,\n";
				}
				return str_replace("[content]",$arrayString,$defultsContent);
				
			}
			function replaceFunContent($search,$replace){
				$this->functionConent = str_replace($search,$replace,$this->getFunctionTemplate());				
			}
			
			function getFunctionTemplate(){
				if(is_null($this->functionConent))
					$this->functionConent = $this->getDefutlsFunctionContent();	
				return $this->functionConent;
			}
			function getDefutlsFunctionContent(){
				return '[contentGlobal]
						[contentDefultsArray]
						[contentMergeArray]
						[contentSelectTop]
						[contentSelectContent]
						[contentSelectTotle]
				';	
			}
	}
